﻿//
// Created by Administrator on 2020/8/21.
//

#include "Time.h"
#include <iostream>

void Time::show() {
    int hour = timeInMinute / 60;
    int minute = timeInMinute % 60;

    std::cout << "hour:" << hour << ", minute:" << minute << std::endl;
}


Time::Time() {
    this->timeInMinute = 0;
}

Time::Time(int timeInMinute) {
    this->timeInMinute = timeInMinute;
}

Time Time::operator+(const Time &time) {
    Time result;
    result.timeInMinute = this->timeInMinute + time.timeInMinute;
    return result;
}

Time Time::operator+(int minute) {
    Time result;
    result.timeInMinute = this->timeInMinute + minute;
    return result;
}

Time::operator int() const {
    return this->timeInMinute;
}

Time operator+(int minute, Time &time) {
    Time result;
    result.timeInMinute = time.timeInMinute + minute;
    return result;
}

std::ostream &operator<<(std::ostream &os, const Time &time) {
    int hour = time.timeInMinute / 60;
    int minute = time.timeInMinute % 60;
    os << "hour:" << hour << ", minute:" << minute << "\n";
    return os;
}